package za.co.smartmi.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class SystemAccount implements Serializable {

    protected SystemUser systemUser;
    protected List<SystemUserRole> systemUserRole;

    public SystemAccount() {
    }

    public SystemUser getSystemUser() {
        return systemUser;
    }

    public void setSystemUser(SystemUser systemUser) {
        this.systemUser = systemUser;
    }

    /**
     * Gets the list of system user roles.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the object.
     * This is why there is not a <CODE>set</CODE> method for the systemUserRole property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getSystemUserRole().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link SystemUserRole }
     * 
     * 
     */
    public List<SystemUserRole> getSystemUserRole() {
        if (systemUserRole == null) {
            systemUserRole = new ArrayList<SystemUserRole>();
        }
        return this.systemUserRole;
    }

    public boolean isAccountPKSet() {
        return getSystemUser() !=null && getSystemUser().getUsername() != null;
    }  
    
    public List<String> getSystemUserRoles() {
        List<String> roles = new ArrayList<String>();
        for (Iterator<SystemUserRole> it = systemUserRole.iterator(); it.hasNext();) {
            SystemUserRole systemUserRole1 = it.next();
            roles.add(systemUserRole1.getRole());
        }
        return roles;
    }
}
